
<?php $baseUrl=Zend_Controller_Front::getInstance()->getBaseUrl(); ?>
<link rel="stylesheet" rev="stylesheet" href="<?php  echo $baseUrl; ?>/css/login.css" type="text/css" media="all" />
<input type="hidden" id="baseUrl" value="<?php echo $baseUrl; ?>"/>
<script type="text/javascript" src="<?php  echo $baseUrl; ?>/js/commonfunctions.js"></script>
<script type="text/javascript" src="<?php  echo $baseUrl; ?>/js/md5.js"></script>
<script type="text/javascript" language="javascript">
   $(document).ready(function()
   {
       $('#notice').css('display','none');
       $('#username').focus();
   }
   );

   function checkLogin()
   {
       var user=$('#username').val();
       var pass=$('#password').val();
       var error="";
       var isError=false;
       if(StandardString(user).length==0)
       {
           error +="Chưa nhập tên đăng nhập !<br/> ";
           isError=true;
       }
       if(StandardString(pass).length==0)
       {
           error +="Chưa nhập mật khẩu !<br/>";
           isError=true;
       }

       if(isError)
       {
           $('#notice').html(error);
           $('#notice').css('display','block');
           $('#username').focus();
           return false;
       }

       var willReturn;
       var baseUrl=$('#baseUrl').val();
       var passEncode=MD5(pass);
       $.ajax({
          type:'GET',
          async: false,
          cache: false,
          timeout: 30000,
          url: baseUrl + '/default/ajax/checkaccount?user='+user+'&pass='+passEncode,
          success:function(data)
          {
            data=parseInt(data);
            if(data!=0)
            {
                $('#password').val(passEncode);
                willReturn=true;
            }
            else
            {
                $('#notice').html("Thông tin đăng nhập không đúng !");
                $('#notice').css('display','block');
                $('#username').focus();
                willReturn=false;
            }
          }
        });

        return willReturn;
   }
</script>
<div class="clear1"></div>
<div id="body_main">
    <div class="clear1"></div>
    <div class="login">
        <div class="header">
            <h4>
                Đăng nhập
            </h4>
        </div>
        <div class="clear"></div>
        <div id="notice" class="notice">
            
        </div>
        <div class="clear"></div>
        <div id="account">
            <form method="POST" action="<?php echo $baseUrl.'/default/index/login'; ?>">
            <table width="60%" cellspacing="0" cellpadding="5px" align="center">
                <tr>
                    <td class="title">
                        Tên đăng nhập:
                    </td>
                    <td>
                        <input class="txt" type="text" name="username" id="username"/>
                    </td>
                </tr>
                <tr>
                    <td class="title">
                        Mật khẩu:
                    </td>
                    <td>
                        <input class="txt" type="password" name="password" id="password"/>
                    </td>
                </tr>
                <tr>
                    <td>
                       &nbsp;
                    </td>
                    <td>
                        <input onclick="return checkLogin();" class="button" type="submit" id="btLogin" name="btLogin" value="Đăng nhập"/>
                        hay
                        <a class="menu" href="<?php echo $baseUrl .'/default/index/register'; ?>">Đăng ký</a><br/><br/>
                        <a class="menu" href="#">Quên mật khẩu?</a>
                    </td>
                </tr>
            </table>
            </form>
        </div>
    </div>
</div>
